﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace GioHangViet.Models
{
    [Table("Users")]
    public class User
    {
        [Key]
        [Required(ErrorMessageResourceType = typeof(Resources.Error), ErrorMessageResourceName = "ErrorUserUserName")]
        [StringLength(30,MinimumLength = 6, ErrorMessageResourceType = typeof(Resources.Error), ErrorMessageResourceName = "ErrorUserUserNameLength")]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserUserName")]
        public string UserName { get; set; }

        [Required(ErrorMessageResourceType = typeof(Resources.Error), ErrorMessageResourceName = "ErrorUserPassword")]
        [StringLength(32, MinimumLength = 6, ErrorMessageResourceType = typeof(Resources.Error), ErrorMessageResourceName = "ErrorUserPasswordLength")]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserPassword")]
        [DataType(DataType.Password)]
        public string Password { get; set; }

        [Required(ErrorMessageResourceType = typeof(Resources.Error), ErrorMessageResourceName = "ErrorUserEmail")]
        [StringLength(50, ErrorMessageResourceType = typeof(Resources.Error), ErrorMessageResourceName = "ErrorUserEmailLength")]
        [RegularExpression(@"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$", ErrorMessageResourceType = typeof(Resources.Error), ErrorMessageResourceName = "ErrorUserEmailFormat")]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserEmail")]
        public string Email { get; set; }

        [StringLength(250, ErrorMessageResourceName = "ErrorUserAddressLength", ErrorMessageResourceType = typeof(Resources.Error))]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserAddress")]
        public string Address { get; set; }

        [StringLength(50, ErrorMessageResourceName = "ErrorUserProviceLength", ErrorMessageResourceType = typeof(Resources.Error))]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserProvice")]
        public string Provice { get; set; }

        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserLastestLogon")]
        public DateTime LastestLogon { get; set; }

        [StringLength(50, ErrorMessageResourceName = "ErrorUserDistrictLength", ErrorMessageResourceType = typeof(Resources.Error))]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserDistrict")]
        public string District { get; set; }

        [StringLength(50, ErrorMessageResourceName = "ErrorUserWardLength", ErrorMessageResourceType = typeof(Resources.Error))]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserWard")]
        public string Ward { get; set; }

        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserCreateDate")]
        public DateTime CreateDate { get; set; }

        [StringLength(50, ErrorMessageResourceName = "ErrorUserSecretKeyLength", ErrorMessageResourceType = typeof(Resources.Error))]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserSecretKey")]
        public string SecretKey { get; set; }

        [StringLength(20, ErrorMessageResourceName = "ErrorUserAvatarLength", ErrorMessageResourceType = typeof(Resources.Error))]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserAvatar")]
        public string Avatar { get; set; }

        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserBirthday")]
        public DateTime Birthday { get; set; }

        [Required(ErrorMessageResourceName = "ErrorUserGender", ErrorMessageResourceType = typeof(Resources.Error))]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserGender")]
        public byte Gender { get; set; }

        [Required(ErrorMessageResourceName = "ErrorUserFullName", ErrorMessageResourceType = typeof(Resources.Error))]
        [StringLength(50, ErrorMessageResourceName = "ErrorUserFullNameLength", ErrorMessageResourceType = typeof(Resources.Error))]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserFullname")]
        public string Fullname { get; set; }

        /// <summary>
        /// mặc định là 0 nghĩa là người dùng thông thường.
        /// 1 admin
        /// </summary>
        [DefaultValue(0)]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserGroupId")]
        public byte GroupId { get; set; }

        [DefaultValue(false)]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserTrackNews")]
        public Boolean TrackNews { get; set; }

        [DefaultValue(0)]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserMoney")]
        public decimal Money { get; set; }

        [DefaultValue(0)]
        [Display(ResourceType = typeof(Resources.Displaies), Name = "DisplayUserIntroCount")]
        public byte IntroCount { get; set; }

    }
}